package com.liit.front.controller;

import java.util.ArrayList;
import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import com.liit.front.filter.WebContext;
import com.liit.module.dto.PathDto;
import com.liit.module.entity.OnlineLink;
import com.liit.module.frame.utils.FileUtil;
import com.liit.module.frame.utils.page.Pagination;
import com.liit.module.service.FilesService;
import com.liit.module.service.OnlineLinkService;

/**
 * @author dingweibo
 * @Title: OnlineController.java
 * @Description: 线上购物
 * @date 2015年12月4日
 */
@Controller
@RequestMapping(value = "/online")
public class OnlineController {

	@Resource
	OnlineLinkService onlineLinkService;

	@Resource
	FilesService filesService;

	/**
	 * 产品项
	 * 
	 * @return
	 */
	@RequestMapping(value = "/buyLink")
	public String buyLink() {
		List<OnlineLink> list = (List<OnlineLink>) onlineLinkService.listPage(new Pagination(), new OnlineLink()).get("list");
		List<PathDto> paths = new ArrayList<PathDto>();
		for (OnlineLink record : list) {
			PathDto dto = new PathDto();
			dto.setName(record.getTitle());
			dto.setContent(record.getContent());
			dto.setPath2(record.getBuyLink());
			dto.setPath(FileUtil.getUrl(filesService.selectById(record.getImgLogo())));
			paths.add(dto);
		}
		WebContext.setAttribute("paths", paths);
		IndexController.navigation();
		return "/online/buyLink";
	}
}
